import { IsNotEmpty } from 'class-validator';
import { Column, Entity, PrimaryGeneratedColumn, Unique } from 'typeorm';

/**
 * 组件
 */
@Entity('book')
export class Book {
  @PrimaryGeneratedColumn('uuid')
  id: number;

  @Column({
    comment: '昵称',
    nullable: true,
    default: '',
  })
  @IsNotEmpty()
  @Unique(['fileName'])
  fileName: string;

  @Column({
    comment: '背景图',
    default: '',
  })
  @IsNotEmpty()
  cover: string;

  @Column({
    comment: '标题',
    nullable: true,
    default: '',
  })
  @IsNotEmpty()
  title: string;

  @Column({
    comment: '类型',
    nullable: true,
    default: '',
  })
  @IsNotEmpty()
  type: string;

  @Column({
    comment: '作者',
    nullable: true,
    default: '',
  })
  @IsNotEmpty()
  author: string;

}
